/**
 * model
 */
class model extends eui.Component{
    private msg:eui.Label;
    private cancel:eui.Button;
    private require:eui.Button;
    private _msg:any;
    private _id:number = 0;
    private maskBg:egret.Shape;
    public constructor(msg){
        super();
       // this.cacheAsBitmap =true;
        this._msg = msg;
        this.addEventListener(eui.UIEvent.COMPLETE , this.createCompleteEvent,this);
        this.skinName = "modelSkin"; 
    }

    private createCompleteEvent():void{
        this.removeEventListener(eui.UIEvent.COMPLETE , this.createCompleteEvent, this);
        this.msg.text = this._msg;
        this.cancel.addEventListener(egret.TouchEvent.TOUCH_TAP,()=>{
            this.parent.removeChild(this);
        },this);
        this.require.addEventListener(egret.TouchEvent.TOUCH_TAP,()=>{
            this.dispatchEventWith("delete",true,this._id);
        },this);

        this.maskBg = new egret.Shape();
        this.maskBg.graphics.beginFill(0x000000,0.6);
        this.maskBg.graphics.drawRect(0,0,common.stageW,common.stageH);
        this.maskBg.graphics.endFill();
        this.maskBg.touchEnabled = true;
        this.addChild(this.maskBg);
        this.setChildIndex(this.maskBg,0);

        this.maskBg.addEventListener(egret.TouchEvent.TOUCH_TAP,()=>{
            this.parent.removeChild(this);
        },this);
    }
    public show(msg){
        this.msg.text = msg;
    }

    public set Id(n:number){
        this._id = n;
    }
    public get Id():number{
        return this._id;
    }
}